package com.hj.service.imp;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;

import com.hj.domain.Studentinfo;
import com.hj.exception.CustomException;
import com.hj.mapper.StudentinfoMapper;
import com.hj.service.inter.StudentServiceInter;


//功能性异常建议在service中抛出
public class StudentServiceImp implements StudentServiceInter {

	@Autowired
	private StudentinfoMapper studentinfoMapper;

	@Override
	public List<Studentinfo> getOnlyUser(Map<String, Object> param)throws Exception {
		// TODO Auto-generated method stub
		List<Studentinfo> list=studentinfoMapper.getOnlyUser(param);
		if(list.size()==0){
			throw  new CustomException("用户不存在!");
		}
		return list;
	}

	@Override
	public boolean insertUser(Studentinfo studentinfo) throws Exception {
		// TODO Auto-generated method stub
		boolean b=studentinfoMapper.insertUser(studentinfo);
		if(b==false){
			throw  new CustomException("注册失败!");
		}
		return b;
	}

	@Override
	public boolean updateUser(Map<String, Object> map) throws Exception {
		// TODO Auto-generated method stub
		boolean b=studentinfoMapper.updateUser(map);
		if(b==false){
			throw  new CustomException("用户信息更新失败!");
		}
		return b;
	}

	@Override
	public List<Studentinfo> queryAllUser() throws Exception {
		// TODO Auto-generated method stub
		List<Studentinfo> list=studentinfoMapper.queryAllUser();  
		if(list.size()==0){
			throw  new CustomException("查询用户信息失败!");
		}
        return list; 
	}

		
}
